package io.yunho.spring.boot.rocketmq.controller;

import io.yunho.spring.boot.rocketmq.basic.SpringProducer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: Jason
 * @date: 2021/4/12 14:37
 * @description:
 */
@RestController
@RequestMapping("/MQTest")
public class RocketMQController {
    private final String topic = "TestTopic";
    @Resource
    private SpringProducer producer;
    @GetMapping("/send")
    public String sendMessage(String message){
        producer.sendMessage(topic,message);
        return "消息发送完成";
    }

    @GetMapping("/sendtrans")
    public String sendTransactionMsg(String message) throws InterruptedException {
        producer.sendTransactionMessage(topic,message);
        return "消息发送完成";
    }
}
